package com.yingma.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yingma.system.entity.JcRegistration;
import com.yingma.system.dao.JcRegistrationDao;
import com.yingma.system.entity.JcVehicleHead;
import com.yingma.system.service.JcRegistrationService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (JcRegistration)表服务实现类
 *
 * @author makejava
 * @since 2020-04-02 19:10:47
 */
@Service("jcRegistrationService")
public class JcRegistrationServiceImpl implements JcRegistrationService {

    @Resource
    private JcRegistrationDao jcRegistrationDao;

    /**
     * 根据条件查询注册公司信息
     * @param companyName
     * @param pageNum
     * @param pageSize
     * @return
     */
    @Override
    public List<JcRegistration> searchRegisterCompany(String companyName, Integer pageNum, Integer pageSize) {
        List<JcRegistration> list=null;
        QueryWrapper<JcRegistration> queryWrapper=new QueryWrapper<JcRegistration>();
        if(!companyName.equals("")&&companyName!=""){
            queryWrapper.like("NAME",companyName);
        }
        Page<JcRegistration> page=new Page<>(pageNum,pageSize,true);
        IPage<JcRegistration> iPages=jcRegistrationDao.selectPage(page,queryWrapper);
        list=iPages.getRecords();
        if(list.size()>0){
            list.get(0).setTotalpageNum(new Long(iPages.getPages()).intValue());
            list.get(0).setTotalSize(new Long(iPages.getTotal()).intValue());
        }
        return list;
    }
}
